#include "widget.h"
#include "ui_widget.h"
#include <QMouseEvent>
#include <QEvent>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::mousePressEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        qDebug() << "按下左键";
    }
}

bool Widget::event(QEvent *event)
{
    if(event->type() == QEvent::MouseButtonPress)
    {
        qDebug() << "QEvent按下鼠标按键";
        return true; // 代表不想下分发
    }
    // 其他时间交给父类进行默认处理
    return QWidget::event(event);
}

